<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@ page import="com.wlcorp.forcazamis.domain.stock.Stock"%>
<%@ page import="com.wlcorp.forcazamis.domain.stock.StockProduct"%>
<%@ page import="com.wlcorp.forcazamis.domain.stock.StockProductDetail"%>
<%@ page import="com.wlcorp.forcazamis.domain.system.Company"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.CommonUtil"%>
<%@ page import="com.wlcorp.forcazamis.sys.util.DateUtil"%>

<%
	Stock stock = (Stock) request.getAttribute("stock");
	List stockProductList = (List) request.getAttribute("stockProductList");
	List factoryList = (List) request.getAttribute("factoryList");
	Company company=(Company) request.getAttribute("company");
%>
<html>
<head>
<title>采购合同打印</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<link href="${pageContext.request.contextPath}/css/print.css"
	rel=stylesheet>
<style media="print">
</style>
<script language="javascript"
	src="${pageContext.request.contextPath}/script/common.js"></script>
<style media=print>
.Noprint {
	display: none;
}

.PageNext {
	page-break-after: always;
}
</style>
<script>  
function  window.onload()  {  
   factory.printing.header  =  ""  
   factory.printing.footer  =  ""  
   factory.printing.portrait = true;
   factory.printing.leftMargin  =  5  
   factory.printing.topMargin  =  5  
   factory.printing.rightMargin  =  5  
   factory.printing.bottomMargin  =  5  
   }  
   function exportStock(stockId){
		    parent.location = "${pageContext.request.contextPath}/stock/stockManager.do?method=exportStock&stockId=" + stockId;
		}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0
	id=wb name=wb width=0> </OBJECT>
<object id="factory" style="display: none" viewastext
	classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
	codebase="http://successoptical.com/mis/download/ScriptX.cab">
</object>
<right>
<input type="hidden" value="<%=stock.getStockId()%>">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class=Noprint>
	<tr>
		<td align="right"><input type="button" name="Button" value="打印预览"
			onclick="wb.execwb(7,1)"> <input type="button" name="Button"
			value=" 打  印 " onclick="window.print();"> <input
			type="button" name="Button2" value=" 保  存 " onClick="wb.execwb(4,1)">
		<input type="button" name="Button22" value=" 导  出 "
			onClick="exportStock('<%=stock.getStockId()%>')">
		<input type="button" onclick="window.close()" value="关闭窗口"></td>
	</tr>
</table>
<div align="right">
<table width="98%" border="0" cellspacing="0" cellpadding="10">
	<tr>
		<td align="center"><b><font face="楷体_GB2312"
			class="big_title">&nbsp;货物买卖合同</font> [ <span class="title_middle"><font
			color="#0000FF"><%=stock.getStockType() %>·<%=CommonUtil.nullToStr(stock.getStockTypeName())%></font></span></b>
		]</td>
	</tr>
</table>

<table width="95%" border="0" cellpadding="0" cellspacing="0" class="tbprint">
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table width="98%" border="0" cellspacing="0" cellpadding="0" class="tbprint">
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">甲方：</span></td>
						<td class="tdprint_2"><span class="title_middle"><%=CommonUtil.nullToStr(company.getCfullName())%></span></td>
						<td width="150" class="tdprint_2" align="center"><span class="title_middle">代表(签字)</span></td>
					</tr>
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">地址：</span></td>
						<td class="tdprint_2"><span class="title_middle"><%=CommonUtil.nullToStr(company.getCaddress())%></span></td>
						<td rowspan="2" class="tdprint_2">&nbsp;</td>
					</tr>
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">电话：</span></td>
						<td class="tdprint_2"><span class="title_middle"><%=CommonUtil.nullToStr(company.getPhone())%></span></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>
				<table width="98%" border="0" cellspacing="0" cellpadding="0" class="tbprint">
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">乙方：</span></td>
						<td class="tdprint_2"><span class="title_middle"><%=CommonUtil.nullToStr(stock.getFactory().getFactoryFullName())%></span></td>
						<td width="150" class="tdprint_2" align="center"><span class="title_middle">代表(签字)</span></td>
					</tr>
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">地址：</span></td>
						<td class="tdprint_2"><span class="title_middle"><%=CommonUtil.nullToStr(stock.getFactory().getAddress())%></span></td>
						<td rowspan="2" class="tdprint_2">&nbsp;</td>
					</tr>
					<tr>
						<td align="right" height="25" width="60" class="tdprint_2"><span class="title_middle">电话：</span></td>
						<td class="tdprint_2"><span class="title_middle"> </span></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td align="right" width="230" valign="top">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table border="0" cellspacing="0" cellpadding="0" class="tbprint">
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle"><nobr>合同编号：</nobr></span></td>
						<td class="tdprint_2" align="center" width="180"><span
							class="title_middle"><nobr><b><%=CommonUtil.nullToStr(stock.getStockCode())%>&nbsp;<%=stock.getStockLevelName() %></b></nobr></span></td>
					</tr>
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle">签订日期：</span></td>
						<td align="center" class="tdprint_2" width="180"><span
							class="title_middle"><b><%=DateUtil.toDateString(stock.getStockDate())%></b></span></td>
					</tr>
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle">交货日期：</span></td>
						<td align="center" class="tdprint_2" width="180"><span
							class="title_middle"><b><%=CommonUtil.nullToStr(stock.getDeliveryDate())%></b></span></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>
				<table border="0" cellspacing="0" cellpadding="0" class="tbprint">
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle"><nobr>编写人：</nobr></span></td>
						<td class="tdprint_2" align="center" width="180"><span
							class="title_middle"><nobr></nobr></span></td>
					</tr>
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle">审核人：</span></td>
						<td align="center" class="tdprint_2" width="180"><span
							class="title_middle"></span></td>
					</tr>
					<tr>
						<td align="right" class="tdprint_2" width="80" height="25"><span
							class="title_middle">复核人：</span></td>
						<td align="center" class="tdprint_2" width="180"><span
							class="title_middle"></span></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<br>
<table width="95%" border="0" cellspacing="0" cellpadding="5" class="tbprint">
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span class="title_big"><font
			face="楷体_GB2312" ><b>一、合同条款:</b></font></span></td>
	</tr>
	<tr>
		<td valign="top"><span class="title_middle">
		1. <b>该合同共&nbsp;<% if (null != stockProductList) {out.print(stockProductList.size());}%>&nbsp;款&nbsp;<%=CommonUtil.nullToStr(stock.getTotalGlasses())%>&nbsp;副, 合同金额￥&nbsp;<%=CommonUtil.format2Scale(stock.getTotalPrice())%>&nbsp;元.</b><br>
		2. 出货前10天提供两套出货样给我司,色样齐全且不计费用.<br>
		3. 结算方式：货款出货后2个月内付清。<br>
		4. 质量要求：交付货物与样品及其说明相同。贵厂根据样品及文字说明进行生产和交付货物。样品可以为我司自行研发的样品和我司提供给贵厂的样品。<br>
		5.
		检验标准和方法：供应商应将本合同项下产品之生产各进程时间及时通知我司，以便我司对配件、白架、电镀和产品等各个生产环节的成品或半成品进行随机质量抽查，供应商必须按我司的质量抽查意见进行调整或无条件返工。产品完成后，供应商应及时通知我司验货并无偿提供每款1套出货样品给我司。本合同项下货物交付后1年时间内，因电镀掉色、焊点堆积和不牢固、配件质量不合格、校架不合格等质量原因而引起的客户索赔或退货之损失由供应商承担；需采用仪器测试的质量索赔（如电镀无镍测试不通过），供应商应自行追究相应供应链的责任人。我司在验货时发现产品质量不合格或存在质量瑕疵但供应商坚持认为可以交付时，供应商应提供质量担保书，经征得我司同意后可以发货。供应商提供的质量担保范围为：我司客户因产品质量原因而进行的索赔、退货时所产生的一切责任和损失。<br>
		6. 包装方式：根据我司提供的“印字包装通知书”。<br>
		7.
		保密：本合同内容为商业秘密，双方均不得向第三方泄露；本合同中产品的款式、印字包装等你方均不得向第三者展示，不得将我司研发或提供的款式产品销售、赠与或以其他方式提供给第三人。<br>
		8.
		供应商必须按时完成确认样,出货样及订单货物,如果不能按时完成,需同我方商量并达成协议.如未达成协议延迟五天以上的,每延迟一天扣货款总额的千分之五,延迟半个月以上的我方有权取消合同.并按实际货款的20%扣除作为弥补客户损失费用.<br>
		9. 供应商必须足量完成确认样,出货样及订单货物，否则不予结算,直至足量交货.<br>
		10. 供应商必须取保产品品质优良,包括确认样，出货样及订单货物,否则不予出货.<br>
		11.供应商未按合同约定时间交付货物时，必须由海运改为空运才能按期交付给我司客户的，我司有权决定改为空运，为此多付出的超过海运费的费用（含相应投保超出费用）由供应商承担；因供应商逾期交付货物，而我司客户的运输方式原本是空运，致使货物不能按期交付给我司客户的，我司有权决定是否同意接收货物：如果我司接受出货，空运费（包含报关费用）及因出货时间不及时引起的我司客户索赔，由供应商承担。<br>
		<br>
		<b>违约责任:按《经济合同法》有关规定执行。</b></td>
	</tr>
	
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>二、品质要求</b></font></span></td>
	</tr>
	<tr>

		<td height="120" valign="top" class="tdprint"><span
			class="title_middle"><%=CommonUtil.nullToStr(stock.getQualityRequire())%></span></td>
	</tr>
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>三、配件要求</b></font></span></td>
	</tr>
	<tr>

		<td height="120" valign="top" class="tdprint"><span
			class="title_middle"><%=CommonUtil.nullToStr(stock.getFittingRequire())%><br />
		</span></td>
	</tr>
</table>

<!-- table width="95%" border="0" cellspacing="0" cellpadding="5" class="tbprint">
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>二、品质要求</b></font></span></td>
	</tr>
	<tr>

		<td height="250" valign="top" class="tdprint"><span
			class="title_middle"><%=CommonUtil.nullToStr(stock.getQualityRequire())%></span></td>
	</tr>
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>三、配件要求</b></font></span></td>
	</tr>
	<tr>

		<td height="200" valign="top" class="tdprint"><span
			class="title_middle"><%=CommonUtil.nullToStr(stock.getFittingRequire())%><br />
		</span></td>
	</tr>
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><b><font face="楷体_GB2312">四、营销总监留言</font></b></span></td>
	</tr>
	<tr>

		<td height="100" valign="top" class="tdprint"><span
			class="title_middle"><b></b></span></td>
	</tr>
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>五、货源部留言</b></font></span></td>
	</tr>
	<tr>

		<td height="100" valign="top" class="tdprint"><span
			class="title_middle"><b></b></span></td>
	</tr>
	<tr valign="top">
		<td height="10" class="tdprint" bgcolor="f1f1f1"><span
			class="title_big"><font face="楷体_GB2312"><b>六、工厂留言</b></font></span></td>
	</tr>
	<tr>

		<td height="100" valign="top" class="tdprint"><span
			class="title_middle"></span></td>
	</tr>
</table -->


<%
      		if (null != stockProductList) {
      			for (int i = 0; i < stockProductList.size(); i++) {
      				StockProduct stockProduct = (StockProduct) stockProductList.get(i);
      %> 
<table width="95%" border="0" cellspacing="0" cellpadding="2">
	<tr>
		<td><span class="title_middle"><b>【<%=stock.getStockCode() %>&nbsp;<%=CommonUtil.nullToStr(stock.getStockLevelName())%>】
		第 <%=i+1%> 款 / 共 <%=stockProductList.size()%> 款</b></span></td>
	</tr>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td colspan="3" height="30"><span class="title_middle"><font
			color=#FF0000><i><b><%=CommonUtil.nullToStr(stockProduct.getHeadExplain())%></b></i></font></span></td>
	</tr>
	<tr>
		<td width="40%">
		<table width="100%" border="0" cellspacing="0" cellpadding="0"
			class="tbprint">
			<tr>
				<td height="25" class="tdprint"><span class="title_middle">我司型号：<%=CommonUtil.nullToStr(stockProduct.getMyCode())%></span></td>
			</tr>
			<tr>
				<td height="25" class="tdprint"><span class="title_middle">工厂型号：<%=CommonUtil.nullToStr(stockProduct.getFactoryCode())%></span></td>
			</tr>
			<tr>
				<td height="25" class="tdprint"><span class="title_middle">生产工厂：</span></td>
			</tr>
		</table>
		</td>
		<td width="5%">&nbsp;</td>
		<td width="55%">
		<table width="100%" border="0" cellspacing="0" cellpadding="0"
			class="tbprint">
			<tr>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">附图尺寸：<%=CommonUtil.nullToStr(stockProduct.getFigureSize())%></span></td>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">窗形更改：<%=CommonUtil.nullToStr(stockProduct.getWindowChange())%></span></td>
			</tr>
			<tr>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">订单尺寸：<%=CommonUtil.nullToStr(stockProduct.getOrderSize())%></span></td>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">鼻梁更改：<%=CommonUtil.nullToStr(stockProduct.getNoseChange())%></span></td>
			</tr>
			<tr>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">生产档次：<%=CommonUtil.nullToStr(stockProduct.getLevel())%></span></td>
				<td height="25" class="tdprint" width="50%"><span
					class="title_middle">客户品牌：<%=CommonUtil.nullToStr(stockProduct.getCustomerBrand())%></span></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<br>

<table width="95%" border="0" cellpadding="2" class="tbprint"
	cellspacing="0">
	<tr align="center">
		<td height="25" class="tdprint"><span class="title_middle"><nobr>印字型号</nobr></span></td>
		<td height="25" class="tdprint"><span class="title_middle"><nobr>印字颜色</nobr></span></td>
		<td height="25" class="tdprint"><span class="title_middle"><nobr>印字尺寸</nobr></span></td>
		<td height="25" class="tdprint"><span class="title_middle"><nobr>
			<%if(CommonUtil.nullToStr(stockProduct.getMyCode()).endsWith("B")||CommonUtil.nullToStr(stockProduct.getMyCode()).endsWith("Z")) {out.print("架面颜色");}else{out.print("电镀颜色");}%>
		</nobr></span></td>
		<td height="25" class="tdprint"><span class="title_middle"><nobr>
			<%if(CommonUtil.nullToStr(stockProduct.getMyCode()).endsWith("B")||CommonUtil.nullToStr(stockProduct.getMyCode()).endsWith("Z")) {out.print("镜腿颜色");}else{out.print("脚套颜色");}%>
		</nobr></span></td> 
		<td height="25" class="tdprint"><span class="title_middle"><nobr>备注</nobr></span></td>
		<td class="tdprint"><span class="title_middle">付数</span></td>
		<td class="tdprint"><span class="title_middle">单价</span></td>
	</tr>
	<%
	long nums=0;
	float prices=0;
	if (null != stockProduct.getStockProductDetailSet()&& stockProduct.getStockProductDetailSet().size() > 0) {
		for (Iterator iter = stockProduct.getStockProductDetailSet().iterator(); iter.hasNext();) {
			StockProductDetail stockProductDetail = (StockProductDetail) iter.next();
			if (stockProductDetail.isDeleteFlag() == true) {
				continue;
			}
			if(null!=stockProductDetail.getAmount()&&!stockProductDetail.getAmount().equals("")){
				nums+=stockProductDetail.getAmount();
				if(null!=stockProductDetail.getUnitPrice()&&!stockProductDetail.getUnitPrice().equals("")){
					prices+=stockProductDetail.getUnitPrice()*stockProductDetail.getAmount();
				}
			}
	%>
	<tr>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getLetteringCode())%></span></td>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getLetteringColor())%></span></td>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getLetteringSize())%></span></td>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getShelfSurefaceColor())%></span></td>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getShelfCruraColor())%></span></td>
		<td height="25" class="tdprint"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getMemo())%></span></td>
		<td class="tdprint" align="center"><span class="text_small"><%=CommonUtil.nullToStr(stockProductDetail.getAmount())%></span></td>
		<td class="tdprint" align="center"><span class="text_small"><%=CommonUtil.format2Scale(stockProductDetail.getUnitPrice())%></span></td>
	</tr>
	<%
		}
	 }
	%>
	<tr>
		<td height="50" class="tdprint" colspan="5" rowspan="2"><span
			class="title_middle"><%=CommonUtil.nullToStr(stockProduct.getProductExplain())%></span></td>
		<td height="25" class="tdprint" align="right"><span
			class="title_middle"><nobr>合计付数：&nbsp;</nobr></span></td>
		<td class="tdprint" align="center" colspan="2">&nbsp;<span
			class="title_middle"><%=nums%>付</span></td>
	</tr>
	<tr>
		<td height="25" class="tdprint" align="right"><span
			class="title_middle">合计价格：</span>&nbsp;</td>
		<td class="tdprint" align="center" colspan="2"><nobr><span
			class="title_middle">￥&nbsp;<%=CommonUtil.format2Scale(prices)%></span></nobr></td>
	</tr>
</table>
<br>

<table width="95%" border="0" cellspacing="0" cellpadding="2"
	class="tbprint">
	<tr>
		<td height="25" colspan="2" class="tdprint"><span
			class="title_middle">镜腿描述：<%=CommonUtil.nullToStr(stockProduct.getShelfCrura())%></span></td>
		<td width="34%" class="tdprint"><span class="title_middle">镜腿长度：<%=CommonUtil.nullToStr(stockProduct.getShelfCruraLength())%></span></td>
	</tr>
	<tr>
		<td height="25" width="33%" class="tdprint"><span
			class="title_middle">装头弧度：<%=CommonUtil.nullToStr(stockProduct.getHeadRadian())%></span></td>
		<td width="33%" class="tdprint"><span class="title_middle">装头长度：<%=CommonUtil.nullToStr(stockProduct.getHeadLength())%></span></td>
		<td width="34%" class="tdprint"><span class="title_middle">镜架宽度：<%=CommonUtil.nullToStr(stockProduct.getShelfCruraWidth())%></span></td>
	</tr>
	<tr>
		<td height="25" width="33%" class="tdprint"><span
			class="title_middle">窗丝：<%=CommonUtil.nullToStr(stockProduct.getWindowSilk())%></span></td>
		<td width="33%" class="tdprint"><span class="title_middle">鼻托：<%=CommonUtil.nullToStr(stockProduct.getEctorhinal())%></span></td>
		<td width="34%" class="tdprint"><span class="title_middle">脚套形状：<%=CommonUtil.nullToStr(stockProduct.getCover())%></span></td>
	</tr>
	<tr>
		<td height="25" width="33%" class="tdprint"><span
			class="title_middle">镜腿、窗丝臼螺丝：<%=CommonUtil.nullToStr(stockProduct.getCrura())%></span></td>
		<td width="33%" class="tdprint"><span class="title_middle">镜架弯度：<%=CommonUtil.nullToStr(stockProduct.getFrameCrankle())%></span></td>
		<td width="34%" class="tdprint"><span class="title_middle">镜架斜度：<%=CommonUtil.nullToStr(stockProduct.getFramePitch())%></span></td>
	</tr>
	<tr valign="top">
		<td height="50" colspan="3" class="tdprint"><span
			class="title_middle">注意：<b> <%=CommonUtil.nullToStr(stockProduct.getNotice())%>
		</b></span> <br>
		<span class="title_middle"><b> <%if(null!=stockProduct.getSpecialize()&&stockProduct.getSpecialize().contains(new String("F"))){out.print("该款有新配件，请注意");}%>
		<%if(null!=stockProduct.getSpecialize()&&stockProduct.getSpecialize().contains(new String("C"))){out.print("该款有新颜色，请注意");}%>
		<%if(null!=stockProduct.getSpecialize()&&stockProduct.getSpecialize().contains(new String("S"))){out.print("该款有新结构，请注意");}%>
		</b></span></td>
	</tr>
</table>
<table width="98%" border="0" cellspacing="0" cellpadding="2">
	<%if(null!=stockProduct.getProductImage()&&!stockProduct.getProductImage().equals("")){
 %>
 
	<tr>
		<td height="200" align="center"><img width="700px"
			src="${pageContext.request.contextPath}/<%=stockProduct.getProductImage()%>" /></td>
	</tr>
</table>
<%} %>
<%
	  	}
	  	}
	  %>
</div>
</body>
</html>
